package com.meet.app.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.meet.app.R;
import com.meet.app.ui.AddFriendActivity;
import com.meet.framework.adapter.CloudTagAdapter;
import com.meet.framework.base.BaseFragment;
import com.meet.framework.helper.FileHelper;
import com.meet.framework.manager.DialogManager;
import com.moxun.tagcloudlib.view.TagCloudView;

import java.util.ArrayList;
import java.util.List;

public class StarFragment  extends BaseFragment implements  View.OnClickListener{


    private TextView tv_star_title;
    private ImageView iv_camera;
    private ImageView iv_add;

    private TagCloudView mCloudView;

    private LinearLayout ll_random;
    private LinearLayout ll_soul;
    private LinearLayout ll_fate;
    private LinearLayout ll_love;

    private List<String> mStarList=new ArrayList<>();

    private CloudTagAdapter mCloudTagAdapter;


    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.fragment_start,null);
        initView(view);
        return view;
    }

    /**
     * 初始化View
     *
     * @param view
     */
    private void initView(View view) {

//        mLodingView = new LodingView(getActivity());
//        mLodingView.setCancelable(false);
//
//        mNullDialogView = DialogManager.getInstance().initView(getActivity(), R.layout.layout_star_null_item, Gravity.BOTTOM);
//        tv_null_text = mNullDialogView.findViewById(R.id.tv_null_text);
//        tv_null_cancel = mNullDialogView.findViewById(R.id.tv_cancel);
//        tv_null_cancel.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                DialogManager.getInstance().hide(mNullDialogView);
//            }
//        });

        iv_camera = view.findViewById(R.id.iv_camera);
        iv_add = view.findViewById(R.id.iv_add);
//        tv_connect_status = view.findViewById(R.id.tv_connect_status);

        tv_star_title = view.findViewById(R.id.tv_star_title);

        mCloudView = view.findViewById(R.id.mCloudView);

        ll_random = view.findViewById(R.id.ll_random);
        ll_soul = view.findViewById(R.id.ll_soul);
        ll_fate = view.findViewById(R.id.ll_fate);
        ll_love = view.findViewById(R.id.ll_love);

        iv_camera.setOnClickListener(this);
        iv_add.setOnClickListener(this);

        ll_random.setOnClickListener(this);
        ll_soul.setOnClickListener(this);
        ll_fate.setOnClickListener(this);
        ll_love.setOnClickListener(this);

//        //数据绑定
        for(int i=0;i<100;i++){
            mStarList.add("star"+i);
        }
        mCloudTagAdapter = new CloudTagAdapter(getActivity(), mStarList);
        mCloudView.setAdapter(mCloudTagAdapter);
//
//        //监听点击事件
//        mCloudView.setOnTagClickListener(new TagCloudView.OnTagClickListener() {
//            @Override
//            public void onItemClick(ViewGroup parent, View view, int position) {
//                startUserInfo(mStarList.get(position).getUserId());
//            }
//        });
//
//        //绑定接口
//        PairFriendHelper.getInstance().setOnPairResultListener(new PairFriendHelper.OnPairResultListener() {
//
//            @Override
//            public void OnPairListener(String userId) {
//                startUserInfo(userId);
//            }
//
//            @Override
//            public void OnPairFailListener() {
//                mLodingView.hide();
//                Toast.makeText(getActivity(), getString(R.string.text_pair_null), Toast.LENGTH_SHORT).show();
//            }
//        });
//
//        loadStarUser();
    }


    @Override
    public void onClick(View v) {
        int viewId=v.getId();
        if(viewId==R.id.iv_add){   //添加好友
           startActivity(new Intent(getActivity(), AddFriendActivity.class));
        }


    }


}
